package com.itheima.health.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("test")
public class TestSecurityController {

    //有add权限的人可以访问
    @PreAuthorize("hasAuthority('add')")
    @RequestMapping("addData")
    public String add(){
        return "add ok";
    }

    //有update权限的人可以访问
    @PreAuthorize("hasAuthority('update')")
    @RequestMapping("updateData")
    public String update(){
        return "update ok";
    }

    //有update权限的人可以访问
    @PreAuthorize("hasAuthority('delete')")
    @RequestMapping("delData")
    public String delData(){
        return "delete ok";
    }

    //有find权限的人可以访问
    @PreAuthorize("hasAuthority('find')")
    @RequestMapping("findData")
    public String findData(){
        return "find ok";
    }
}
